package org.springblade.modules.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tenant.annotation.TenantIgnore;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.admin.entity.MaintainCheckGuide;
import org.springblade.modules.admin.entity.MaintainCheckGuideType;
import org.springblade.modules.admin.service.MaintainCheckGuideService;
import org.springblade.modules.admin.service.MaintainCheckGuideTypeService;
import org.springblade.modules.admin.vo.CheckGuideTypeVO;
import org.springblade.modules.admin.vo.MaintainCheckGuideVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Date 14:48 2021/12/22
 * @Description {
 *   CheckGuideTypeController
 * }
 * @Author lsay
 **/
@RestController
@RequestMapping("/check/guide")
public class CheckGuideController {

	@Autowired
	private MaintainCheckGuideService checkGuideService;

	@GetMapping("/page")
	@TenantIgnore
	public R<IPage<MaintainCheckGuideVO>> selectPage(Long typeId, String name, Query query){
		return R.data(checkGuideService.selectPage(Condition.getPage(query),typeId,name));
	}


	@PostMapping()
	public R<Boolean> save(@RequestBody MaintainCheckGuide checkGuide){
		return R.data(checkGuideService.save(checkGuide));
	}

	@PutMapping()
	public R<Boolean> update(@RequestBody MaintainCheckGuide checkGuide){
		return R.data(checkGuideService.updateById(checkGuide));
	}

	@DeleteMapping
	public R<Boolean> remove(String ids){
		return R.data(checkGuideService.removeByIds(Func.toLongList(ids)));
	}

}
